<?php
if($_SESSION['newUserChecked'] != 1)
{
	$_SESSION['newUserChecked'] = 1;
	
	//prüfen ob der User schon angelegt ist
	$query_nu = mysql_query("SELECT * FROM `benutzer` WHERE `login`='".$_SESSION['username']."'");
	$num_nu = mysql_num_rows($query_nu);
	
	if($num_nu == 0)
	{
		$name = strtok($_SESSION['gecos'],',');
		$firma = strtok(',');
		if(!$firma || $firma == "") $firma = "DHBW Stuttgart";
		$query_nu2 = mysql_query("INSERT INTO `bestellungen`.`benutzer` (`id_user`, `login`, `kurs`, `name`, `firma`, `email`) VALUES (NULL, '".$_SESSION['username']."', '".$_SESSION['kurs']."', '".$name."', '".$firma."', '".$_SESSION['mail']."')") or die (mysql_error());
		$aff_nu2 = mysql_affected_rows();
	}
}
?>